﻿<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../ThirdParty/xs3p/xs3p.xsl"?>
<?xml-stylesheet type="text/xsl" href="../ThirdParty/xsd2html.xsl?>
<!--
     AUTHOR:  Ryan D. Marshall
              ryan.marshall@slalom.com
              
       DATE:  January 31, 2011
       
DESCRIPTION:  Enhanced Windows Azure schema and type definitions for Windows Azure 
              Accelerators project.

-->
<xs:schema
    id="ServiceAcceleratorConfigurationSchema"
    targetNamespace="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceAcceleratorConfiguration"
    elementFormDefault="qualified"
    xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceAcceleratorConfiguration"
    xmlns:sd="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <!--<xs:import namespace="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" schemaLocation="file://C:/Program Files (x86)/Microsoft Visual Studio 10.0/Xml/Schemas/ServiceConfigurationSchema.xsd"/>-->
    <xs:import namespace="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaLocation="file://C:/Program Files (x86)/Microsoft Visual Studio 10.0/Xml/Schemas/ServiceDefinitionSchema.xsd" />

    <!-- 
    ~~~~( SERVICE ACCELERATOR )~~~~
    -->
    <xs:element name="ServiceAccelerator" type="ServiceAccelerator" />
    
    <xs:complexType name="ServiceAccelerator">

            <xs:annotation>
                <xs:documentation>
                    The Windows Azure Accelerators engine's service configuration and definition schema. Used
                    in conjuntion with the base Application definitions to provide the runtime implementation
                    of the base application requirements.

                    Ensure that the service and role names match the names as declared in the .cscfg and
                    .csdef files.
                </xs:documentation>
            </xs:annotation>

                <xs:sequence minOccurs="0" maxOccurs="unbounded">
                    <xs:element name="AcceleratorRole" type="AcceleratorRole" />
                </xs:sequence>

    </xs:complexType>

    <!-- 
    ~~~~( WEB ROLE )~~~~
    -->
    <xs:complexType name="AcceleratorRole" >
        <xs:annotation>
            <xs:documentation>
                The configuration of an accelerator web role which accepts external requests.
            </xs:documentation>
        </xs:annotation>
        <xs:all>
            <xs:element name="Sites" type="Sites" minOccurs="0" maxOccurs="1" />
            <xs:element name="CloudResources" type="CloudResources" minOccurs="0" maxOccurs="1" />
            <xs:element name="Replication" type="Replication" minOccurs="0" maxOccurs="1" />
            <xs:element name="Platform" minOccurs="0" maxOccurs="1" />
            <!--<xs:element name="Imports" type="sd:Imports" minOccurs="0" maxOccurs="1" />-->
            <!--<xs:element name="Startup" type="Startup" minOccurs="0" maxOccurs="1" />-->
            <!--<xs:element name="LocalResources" type="sd:LocalResources" minOccurs="0" maxOccurs="1" />-->
            <!--<xs:element name="LocalStorage" type="sd:LocalStore" minOccurs="0" maxOccurs="1" />-->
            <!--<xs:element name="ConfigurationSettings" type="sd:ConfigurationSettings" minOccurs="0" maxOccurs="1"/>-->
            <!--<xs:element name="InputEndpoints" minOccurs="0" maxOccurs="1">
                <xs:complexType>
                    <xs:annotation>
                        <xs:documentation>
                            A set of endpoints that can be exposed by the service.
                        </xs:documentation>
                    </xs:annotation>
                    <xs:sequence minOccurs="1" maxOccurs="2">
                        <xs:element name="InputEndpoint">
                            <xs:annotation>
                                <xs:documentation>
                                    An endpoint of a service specifies the transport protocol and port on which the service receives requests.
                                </xs:documentation>
                            </xs:annotation>
                            <xs:complexType>
                                <xs:complexContent>
                                    <xs:restriction base="sd:InputEndpoint">
                                        <xs:attribute name="protocol" use="required">
                                            <xs:simpleType>
                                                <xs:restriction base="sd:Protocol">
                                                    <xs:enumeration value="http" />
                                                    <xs:enumeration value="https" />
                                                </xs:restriction>
                                            </xs:simpleType>
                                        </xs:attribute>
                                    </xs:restriction>
                                </xs:complexContent>
                            </xs:complexType>
                        </xs:element>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name="InternalEndpoint" minOccurs="0" maxOccurs="1">
                <xs:complexType>
                    <xs:complexContent>
                        <xs:restriction base="sd:InternalEndpoint">
                            <xs:attribute name="protocol" use="required" >
                                <xs:simpleType>
                                    <xs:restriction base="sd:InternalProtocol">
                                        <xs:enumeration value="http" />
                                    </xs:restriction>
                                </xs:simpleType>
                            </xs:attribute>
                        </xs:restriction>
                    </xs:complexContent>
                </xs:complexType>
            </xs:element>
            <xs:element name="Endpoints" type="sd:Endpoints" minOccurs="0" maxOccurs="1"/>
            <xs:element name="Certificates" type="sd:Certificates" minOccurs="0" maxOccurs="1" />
            <xs:element name="Runtime" minOccurs="0" maxOccurs="1" type="sd:Runtime"/>-->
        </xs:all>
        <xs:attribute name="name" type="NamedElementNameString" use="required">
            <xs:annotation>
                <xs:documentation>
                    The name of the role. Each role should have a unique name.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <!--<xs:attribute name="enableNativeCodeExecution" type="xs:boolean" default="true">
            <xs:annotation>
                <xs:documentation>
                    Allow the execution of native x64 code in this role. Also enables full trust managed code.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="vmsize" type="sd:RoleSize" default="Small">
            <xs:annotation>
                <xs:documentation>
                    The size of the VM needed to host this role.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>-->
    </xs:complexType>
    
    <!--
    ~~~~( CERTIFICATES )~~~~
    -->
    <!--<xs:complexType name="Certificates">
        <xs:annotation>
            <xs:documentation>
                Declaration of all certificates that need to be deployed.
            </xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:element name="Certificate" type="Certificate" minOccurs="0" maxOccurs="unbounded" />
        </xs:sequence>
    </xs:complexType>
    
    <xs:complexType name="Certificate">
        <xs:annotation>
            <xs:documentation>
                A certificate setting is a mapping of a name of a certificate to the identifying value (ie. SHA1 thumbprint).
            </xs:documentation>
        </xs:annotation>
        <xs:complexContent>
            <xs:extension base="sd:Certificate">
                <xs:attribute name="thumbprint" type="sc:ThumbprintType" use="required">
                    <xs:annotation>
                        <xs:documentation>
                            The digest (or thumbprint) of the certificate data used to uniquely identify a certificate.
                        </xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attribute name="thumbprintAlgorithm" type="sc:ThumbprintAlgorithmTypes" use="required">
                    <xs:annotation>
                        <xs:documentation>
                            The hash algorithm that generates a digest of data (or thumbprint)
                            for digital signatures such as MD5, SHA1, SHA256. This is different than
                            the algorithm used in creating the signature inside the certificate.
                        </xs:documentation>
                    </xs:annotation>
                </xs:attribute>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>-->
    
    <!-- 
    ~~~~( SITES )~~~~
    -->
    <xs:complexType name="Sites">
        <xs:annotation>
            <xs:documentation>
                Describes a collection of web sites and web applications that are hosted in the web role.
            </xs:documentation>
        </xs:annotation>
        <xs:sequence minOccurs="0" maxOccurs="unbounded">
            <xs:element name="Site" type="Site" />
        </xs:sequence>
    </xs:complexType>

    <!-- 
    ~~~~( SITE )~~~~
    -->
    <xs:complexType name="Site">
        <xs:annotation>
            <xs:documentation>
                Specifies a web site or web application that is part of the web role.
            </xs:documentation>
        </xs:annotation>
        <xs:complexContent>
            <xs:extension base="VirtualApplication">
                <xs:attribute name="cloudSync" type="xs:string" use="optional">
                    <xs:annotation>
                        <xs:documentation>
                            The name of the cloud storage synchronization resource to use (if any).
                        </xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attribute name="localSync" type="xs:string" use="optional">
                    <xs:annotation>
                        <xs:documentation>
                            The name of the local role file synchronization to use (if any).
                        </xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attributeGroup ref="ApplicationPoolRequirements" />
                <xs:attributeGroup ref="ReplicatedStorageAttributes"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <!--
    ~~~~( APPLICATION )~~~~
    -->
    <xs:attributeGroup name="ApplicationTypeReference">
        <xs:attribute name="acceleratorApplication" type="NamedElementNameString">
            <xs:annotation>
                <xs:documentation>
                    The name of the Accelerator application definition from which to import standard
                    application configuration settings for this site.

                    Use the applicationVersion attribute to differentiate between definitions for
                    applications with multiple different Azure Accelerator configurations.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="acceleratorApplicationVersion" type="xs:string" >
            <xs:annotation>
                <xs:documentation>
                    Optional version attribute is used to differentiate between definitions for
                    applications with multiple different Azure Accelerator configurations.

                    This property is ignored unless more than one definition is found for the
                    application specified in the applicationName property.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:attributeGroup>
    
    <!-- 
    ~~~~( APPLICATION POOL CONFIGURATION )~~~~
    -->
    <xs:attributeGroup name="ApplicationPoolRequirements">
        <xs:annotation>
            <xs:appinfo>
                Specifies the .NET framework runtime version and managed pipeline mode for the web application.
            </xs:appinfo>
        </xs:annotation>
        <xs:attribute name="applicationPoolFrameworkVersion" type="ApplicationPoolFrameworkVersion" />
        <xs:attribute name="managedPipelineMode" type="ManagedPipelineMode" />
    </xs:attributeGroup>

    <!--[ APPLICATION POOL FRAMEWORK VERSION ]-->
    <xs:simpleType name="ApplicationPoolFrameworkVersion">
        <xs:annotation>
            <xs:appinfo>
                Specifies the .NET framework version of the web application pool.
            </xs:appinfo>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:enumeration value="v2.0" >
                <xs:annotation>
                    <xs:appinfo>
                        Application pool set for maximum compatibility with .NET Framework version 2.0, 3.0 and 3.5 based applications.
                    </xs:appinfo>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="v4.0">
                <xs:annotation>
                    <xs:appinfo>
                        Application pool set for .NET 4.0 based web application.
                    </xs:appinfo>
                </xs:annotation>
            </xs:enumeration>        
        </xs:restriction>
    </xs:simpleType>

    <!--[ MANAGED PIPELINE MODE ]-->
    <xs:simpleType name="ManagedPipelineMode">
        <xs:annotation>
            <xs:appinfo>
                Managed pipleline mode settings for the application pool assicated with a virtual application.
            </xs:appinfo>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:enumeration value="Integrated">
                <xs:annotation>
                    <xs:appinfo>
                        Use integrated pipeline mode.
                    </xs:appinfo>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="Classic">
                <xs:annotation>
                    <xs:appinfo>
                        Use Classic managed pipeline mode.
                    </xs:appinfo>
                </xs:annotation>
            </xs:enumeration>
        </xs:restriction>
    </xs:simpleType>
    
    <!-- 
    ~~~~( VIRTUAL DIRECTORIES )~~~~
    -->
    <xs:complexType name="VirtualApplication">
        <xs:annotation>
            <xs:documentation>
                Defines a web application running in IIS.
            </xs:documentation>
        </xs:annotation>
        <xs:complexContent>
            <xs:extension base="VirtualDirectory">
                <xs:attributeGroup ref="ApplicationTypeReference" />
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="VirtualDirectory">
        <xs:annotation>
            <xs:documentation>
                Specifies a directory name that is mapped to a physical directory on the local and remote server.
            </xs:documentation>
        </xs:annotation>
            <xs:sequence>
                <xs:choice minOccurs="0" maxOccurs="unbounded">
                    <xs:element name="VirtualDirectory" type="VirtualDirectory" />
                    <xs:element name="VirtualApplication" type="VirtualDirectory" />
                </xs:choice>
            </xs:sequence>
            <xs:attribute name="name" type="NamedElementNameString" use="required">
                <xs:annotation>
                    <xs:documentation>
                        The name which is reflected in the virtual path.
                    </xs:documentation>
                </xs:annotation>
            </xs:attribute>
            <xs:attribute name="physicalDirectory" type="xs:string" use="optional">
                <xs:annotation>
                    <xs:documentation>
                        The local physical directory location (before deployment). A relative path is
                        assumed to be relative to the location of the csdef.
                    
                        Optional when packaging and deploying via CSPACK and the Windows Azure portal.
                        The physical path can be specified at the CSPACK command line.
                    
                        Required when using the Accelerator process for deploying via storage sync
                        or cloud drive upload.
                    </xs:documentation>
                </xs:annotation>
            </xs:attribute>
            <xs:attribute name="includePhysicalDirectoryFilesInPackage" type="xs:boolean" use="optional" default="true">
                <xs:annotation>
                    <xs:documentation>
                        Specifies whether the packaging process should include all files and folder
                        in the local physical directory in the solution package.

                        If true, all site files will be included in the solution package for upload
                        to Windows Azure.  This is the default Windows Azure behavior.

                        If false, no files will be included in the solutions package.

                        Set this value to false when using one or more of the Azure Accelerator
                        application deployment and maintainence solutions:

                        *  Cloud Drives
                        *  Source Control Delivery
                        *  Blob Synchronization (inter-role; on-presmise)
                    </xs:documentation>
                </xs:annotation>
            </xs:attribute>
            <xs:attribute name="runtimeSolutionCopyBehaviour" use="optional" default="OnCloudDriveCreate">
                <xs:annotation>
                    <xs:documentation>
                        This setting controls how the Accelerator handles files which have been included in
                        the solution package.  The default Windows Azure behavior is to redeploy the exact
                        solution package whenever the instance is restarted or redeployed. All changes made
                        to the running instance are rolled back (or ""healed"").
                    
                        The Accelerator provides for using the files which are in the solution package in
                        a perdetermined set of optional ways.
                    </xs:documentation>
                </xs:annotation>
            </xs:attribute>
            <xs:attribute name="runtimeLocalStorageLocation" type="xs:string" use="optional">
                <xs:annotation>
                    <xs:documentation>
                        The physical directory location on Windows Azure where the virtual directory should point for the runtime
                        location.
                    </xs:documentation>
                </xs:annotation>
            </xs:attribute>
            <xs:attribute name="runtimeCloudSyncLocation" type="VirtualDirectoryName" use="optional">
                <xs:annotation>
                    <xs:documentation>
                        The Windows Azure storage services location to use for synchronization of this physical directory with other
                        running cloud instances or with on-premise file changes.  This location should be unique across all separate customer
                        sites.
                        By default, this will inherit the location of its parent site or virtual directoy.
                    </xs:documentation>
                </xs:annotation>
            </xs:attribute>
            <xs:attribute name="runtimeCloudSyncConnectionStringSetting" type="NamedElementNameString" use="optional">
                <xs:annotation>
                    <xs:documentation>
                        The configuration setting name which has the credentials for connecting to Windows Azure storage.
                        Required when attempting to perform cloud based synchronization across instances.
                    </xs:documentation>
                </xs:annotation>
            </xs:attribute>
    </xs:complexType>

    <!--
    ~~~~( REPLICATION )~~~~
    -->
    <xs:complexType name="Replication">
        <xs:annotation>
            <xs:documentation>
                Synchronize a local physical path with Windows Azure storage service blob storage..
            </xs:documentation>
        </xs:annotation>
        <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element name="CloudSync" type="CloudSync" />
            <xs:element name="LocalSync" type="LocalSync" />
        </xs:choice>
    </xs:complexType>

    <!-- 
    ~~~~( REPLICATED STORAGE ATTRIBUTES )~~~~
    -->
    <xs:attributeGroup name="ReplicatedStorageAttributes">
        <xs:attribute name="cloudStorage" type="xs:string" use="required">
            <xs:annotation>
                <xs:documentation>
                    Name of the cloud storage resource on which site changes are mirrored to other
                    running instances.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="cloudStorageVirtualPath" type="xs:string" use="optional">
            <xs:annotation>
                <xs:documentation>
                    Virtual path in cloud storage which corresponds to this virtual directory.
                    If this path is not defined; the compound site and virtual directory path of this
                    location will be used as the blob storage location.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="cloudDrive" type="xs:string" use="optional">
            <xs:annotation>
                <xs:documentation>
                    Optional cloud drive resources on which this virtual directory exists or
                    should exist and be physically persisted.

                    If the configured drive does not exist (and the cloud drive is set to create); the
                    initial sync behavior will be further defined by the enum.

                    If this attribute is not defined or emply, the site will be run from the existing Azure
                    role location.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="drivePath" type="xs:string" use="optional">
            <xs:annotation>
                <xs:documentation>
                    Path on the cloud drive corresponding to this virtual directory location.
                    If this name is not defined (but a cloud drive is); the compound site and
                    virtual directory path name will be used as the location.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:attributeGroup>

    <!-- 
    ~~~~( CLOUD SYNCH )~~~~
    -->
    <xs:complexType name="CloudSync">
        <xs:annotation>
            <xs:documentation>
                Synchronize a local physical path with Windows Azure storage service blob storage.
            </xs:documentation>
        </xs:annotation>
        <xs:attribute name="name" type="xs:ID" use="required">
            <xs:annotation>
                <xs:documentation>
                    The name by which the local synchronization resource is referenced by other parts of the
                    schema. All replication elements should have unique names.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
            <xs:attribute name="enabled" type="Enabled" use="optional" />
            <xs:attribute name="connectionString" type="xs:string" use="required" />
            <xs:attribute name="cloudSyncUri" type="xs:string" use="required" />
            <xs:attribute name="localSyncPath" type="xs:string" use="required" />
            <xs:attribute name="ignoreAdditionalFiles" default="true" type="xs:boolean" use="optional" />
            <xs:attribute name="direction" type="xs:string" use="required" />
            <xs:attribute name="intervalInSeconds" default="0" type="xs:nonNegativeInteger" use="optional" />
    </xs:complexType>

    <!-- 
    ~~~~( LOCAL SYNC )~~~~
    -->
    <xs:complexType name="LocalSync">
        <xs:annotation>
            <xs:documentation>
                Synchronize a local physical path with another local physical location.
            </xs:documentation>
        </xs:annotation>
        <xs:choice minOccurs="1" maxOccurs="1">
            <xs:element name="LocalStorageReference" type="LocalStorageReference" />
            <xs:element name="CloudDriveReference" type="CloudDriveReference" />
        </xs:choice>
        <xs:attribute name="name" type="NamedElementNameString" use="required">
            <xs:annotation>
                <xs:documentation>
                    The name by which the local synchronization resource is referenced by other parts of the 
                    schema. All replication elements should have unique names.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="enabled" type="xs:boolean" use="optional" />
        <xs:attribute name="source" type="xs:string" use="required" />
        <xs:attribute name="destination" type="xs:string" use="required" />
        <xs:attribute name="mirror" type="xs:boolean" use="optional" />
        <xs:attribute name="intervalInMinutes" default="0" type="xs:int" use="optional" />
    </xs:complexType>

    <xs:complexType name="LocalStorageReference">
        <xs:attribute name="name" type="NamedElementNameString" />    
    </xs:complexType>
    <xs:complexType name="CloudDriveReference">
        <xs:attribute name="name" type="NamedElementNameString" />
    </xs:complexType>
    
    <!--
    ~~~~( CLOUD RESOURCES )~~~~
    -->
    <xs:complexType name="CloudResources">
        <xs:annotation>
            <xs:documentation>
                Lists the cloud storage service resources used by this role. 
            </xs:documentation>
        </xs:annotation>        
        <xs:sequence maxOccurs="unbounded" minOccurs="1">
            <xs:element name="CloudDrive" type="CloudDrive" minOccurs="0" maxOccurs="unbounded" />
            <xs:element name="CloudStorage" type="CloudStorage" minOccurs="0" maxOccurs="unbounded" />
        </xs:sequence>
        <xs:attribute name="cacheLocalStorageName" type="xs:string" use="optional">
            <xs:annotation>
                <xs:documentation>
                    Local storage resource name to use for local cloud drive cache.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="cacheSizeInMB" type="xs:int" use="optional" >
            <xs:annotation>
                <xs:documentation>
                    The total amount of local storage to set aside for use in caching cloud drive content.
                    The cloud drive cache size is used by all cloud drives mounted in the instance.  If this
                    value is not declared, the entire size of the local storage cache location will be used.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="siteLocalStorage" type="xs:string" use="optional">
            <xs:annotation>
                <xs:documentation>
                    Local storage resource name to use for local storage mirroring of
                    read-only cloud drive content in a writeable location.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>

    <!--
    ~~~~( CLOUD STORAGE )~~~~
    -->
    <xs:complexType name="CloudStorage">
        <xs:annotation>
            <xs:documentation>
                Specifies the connection credentails, container and path to a location in blob storage.
            </xs:documentation>
        </xs:annotation>
        <xs:attribute name="name" type="NamedElementNameString" use="required">
            <xs:annotation>
                <xs:documentation>
                    The name by which this cloud drive resource is accessed. It is also the path variable
                    by which it can be referenced in the environment.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="connectionStringSetting" type="NamedElementNameString" use="required">
            <xs:annotation>
                <xs:documentation>
                    The configuration setting name which contains the connection string for Windows Azure storage
                    services where the cloud drive resource is located.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="virtualPath" type="xs:string" use="optional">
            <xs:annotation>
                <xs:documentation>
                    Optional virtual storage location container and path relative to the root
                    of the storage service.  The container and path name must meet the requirements
                    of Windows Azure blob storage.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>
      
    <!--
    ~~~~( CLOUD DRIVE )~~~~
    -->
    <xs:complexType name="CloudDrive">
        <xs:annotation>
            <xs:documentation>
                Configuration of a cloud drive resources. Inherits from a base cloud
                storage definition.
            </xs:documentation>
        </xs:annotation>
        <xs:complexContent>
            <xs:extension base="CloudStorage">
                <xs:attribute name="concurrency" type="CloudDriveSharedAccessType" use="required">
                    <xs:annotation>
                        <xs:documentation>
                            Shared access strategy for this cloud drive.  (Such as a multi-tenant deployment).
                        </xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attribute name="cloudDriveConcurrencyUri" type="xs:anyURI" use="required">
                    <xs:annotation>
                        <xs:documentation>
                            Storage blob used to ensure the correct order of synchronization events amongst
                            multiple instances during startup.
                        </xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attribute name="createSizeInMB" type="xs:int" use="optional" default="1000">
                    <xs:annotation>
                        <xs:documentation>
                            If 0 (zero), no cloud drive will be created if it does not already exist.
                            Otherwise, a cloud drive will be created if one does not exist at the specified
                            location.
                        </xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attribute name="localStorageWriteMirror" type="xs:anyURI" use="optional">
                </xs:attribute>
                <xs:attribute name="cloudStorageWriteMirror" type="xs:anyURI" use="optional">
                </xs:attribute>
                <xs:attributeGroup ref="CloudDriveSyncEvents" />
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <!-- 
    ~~~~( CLOUD DRIVE SHARED ACCESS TYPE )~~~~
    -->
    <xs:simpleType name="CloudDriveSharedAccessType">
        <xs:annotation>
            <xs:documentation>
                Shared access strategy for cloud drives.
            </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:enumeration value="Readonly">
                <xs:annotation>
                    <xs:documentation>
                        Cloud drive will be mounted as a read-only snapshot.
                    </xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="ClonedSnapshot">
                <xs:annotation>
                    <xs:documentation>
                        Cloud drive will be mounted as writeable. If the primary instance is locked
                        a completely new cloud drive will be created using a cloned snapshot of the
                        locked drive image.
                    </xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="LocalStorage">
                <xs:annotation>
                    <xs:documentation>
                        Cloud drive will be mounted as writeable. If the primary instance is locked
                        a readonly snapshot will be mounted and then copied to local storage.  The
                        local storage location will be used to provide runtime write access.
                    </xs:documentation>
                </xs:annotation>                        
            </xs:enumeration>
            <xs:enumeration value="SingleTentant">
                <xs:annotation>
                    <xs:documentation>
                        Cloud drive will be mounted by only a single instance; all others will continue
                        on when encountering a locked resource.
                    </xs:documentation>
                </xs:annotation>
            </xs:enumeration>
        </xs:restriction>
    </xs:simpleType>

    <!-- 
    ~~~~( CLOUD DRIVE CREATE TYPE )~~~~
    -->
    <xs:simpleType name="CloudDriveCreateType">
        <xs:restriction base="xs:string">
            <xs:enumeration value="CreateAppRoot">
                <xs:annotation>
                    <xs:documentation>
                        Copy the solutions files from the uploaded package only if this is the first
                        time the solution has been initialized against a newly provisioned cloud drive.
                        All subsequent deployments or reinitializations will use the files as they
                        exist on the cloud drive and ignore those in the solution.

                        Note:  This includes changed files if the solution is updated and redeployed.
                        Use AllFiles if you wish to overwrite existing files with newly updated solutions
                        files.

                        If the runtime location is not set, this option is ignored, and the normal Windows
                        Azure behavior of running from a read-only package location will be used.

                        If the runtime location is set, but is not a cloud drive location, this option is
                        ignored.
                    </xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="CopySolution">
                <xs:annotation>
                    <xs:documentation>
                        Copy all files from the solution package to the runtime location. Overwrite existing
                        files (on a cloud drive, for example). If the runtime location is not set, this is ignored.
                    </xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="CopyNew">
                <xs:annotation>
                    <xs:documentation>
                        Copies only those solution files which do not exist in the runtime location.  All existing
                        files and folders are ignored.
                    </xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="None">
                <xs:annotation>
                    <xs:documentation>
                        No files copied.
                        Solution files exist only as uploaded in the default deployed solution package location. This
                        is the default behavior of Windows Azure packages.
                    </xs:documentation>
                </xs:annotation>
            </xs:enumeration>
        </xs:restriction>
    </xs:simpleType>

    <!--
    ~~~~( COMMON ATTRIBUTES )~~~~
    -->
    <xs:attributeGroup name="CloudDriveSyncEvents">
        <xs:attribute name="onCloudDriveCreateSyncEvent" type="NamedElementNameString" use="optional">
            <xs:annotation>
                <xs:documentation>
                    The name of the replication event, if any, which should be called the first time
                    a new cloud drive is created.

                    Use this as a means to migrate sites from the solution package upload location to
                    a new cloud drive, or to download a site image from blob storage the very first time
                    a service is run in the cloud.  (An alternative to pre-creating and uploading a
                    cloud drive with the application or sites already deployed).
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="onCloudDriveMountWriteableSyncEvent" type="NamedElementNameString" use="optional">
            <xs:annotation>
                <xs:documentation>
                    The name of the replication event, if any, which should be called when a role
                    achieves an exclusive write lock on a cloud drive resource.

                    Use this to perform file synchronization every time the service is started, but
                    limit the action to the primary persisted role only.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="onCloudDriveMountReadonlySyncEvent" type="NamedElementNameString" use="optional">
            <xs:annotation>
                <xs:documentation>
                    The name of the replication event, if any, which should be called when a role
                    mounts the cloud drive.  This event is called for both read and write mounts.

                    Use this to perform file synchronization every time the service is started on
                    those roles which did not achieve the single writable lock on the cloud drive
                    resource.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:attributeGroup>

    <!--
    ~~~~( TASKS )~~~~
    -->
    <xs:complexType name="PowerShell">
        <xs:annotation>
            <xs:documentation>
                A power shell based startup task.
            </xs:documentation>
        </xs:annotation>
        <xs:complexContent>
            <xs:extension base="Console" />
        </xs:complexContent>
    </xs:complexType>
    
    <xs:complexType name="Console">
        <xs:annotation>
            <xs:documentation>
                A console based application or batch file style start up task.
            </xs:documentation>
        </xs:annotation>
                <xs:attribute name="waitOnExit" use="optional" type="xs:boolean" default="false">
                    <xs:annotation>
                        <xs:documentation>
                            Starts a console application but leaves the command shell open when the batch
                            file finishes.  Useful for debugging in the local development fabric.
                            This option is ignored when running in Azure since it would lock the start up
                            behavior of the role, and by definition cause the service in general to fail.
                            Tip via Smarx, yet again, and again ... (i|rdm)
                        </xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attribute name="redirectOutput" use="optional" type="xs:boolean" default="false">
                    <xs:annotation>
                        <xs:documentation>
                            Starts a console application but leaves the command shell open when the batch
                            file finishes.  Useful for debugging in the local development fabric.
                            This option is ignored when running in Azure since it would lock the start up
                            behavior of the role, and by definition cause the service in general to fail.
                            Tip via Smarx, yet again, and again ... (i|rdm)
                        </xs:documentation>
                    </xs:annotation>
                </xs:attribute>
    </xs:complexType>

    <xs:attributeGroup name="ConsoleOutputDefinition">
        <xs:attribute name="stdOutFile" type="xs:string">
            <xs:annotation>
                <xs:documentation>
                    The name of the file in which to pipe the console standard output during execution.
                    An relative path is assumed to the be in relationship to the DiagnosticsLocalStorage
                    location.  (This provides automated log file upload to blob storage.)
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="errOutFile" type="xs:string" >
            <xs:annotation>
                <xs:documentation>
                    The name of the file in which to pipe the console error output during execution.
                    An relative path is assumed to the be in relationship to the DiagnosticsLocalStorage
                    location.  (This provides automated log file upload to blob storage.)
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:attributeGroup>
      
    <!--
    ~~~~( VARIABLE )~~~~
    -->
    <xs:simpleType name="Variable">
        <xs:union memberTypes="xs:ID NamedElementNameString" />
    </xs:simpleType>
    
    <xs:simpleType name="Enabled">
        <xs:annotation>
            <xs:documentation>
                Optional enabled attribute allows the in-place deactivation of certain facets of
                the Accelerator schema.  A more forgiving alternative to deleting, or commenting
                out, markup as a part of iterative solution development.
                
                The default, 'true', The property is 'true' by default or if not present.
            </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:boolean" />
    </xs:simpleType>


    <!--
    ~~~~( SIMPLE TYPES )~~~~
    -->
    <xs:simpleType name="UncPath">
        <xs:annotation>
            <xs:documentation xml:lang="en">
                A pattern restriction to ensure only valid UNC paths are specified. It restricts the
                boundaries to that which would be a local file system file or directory, or a SMB style
                location.  It will not allow any forward slash based locations.
            </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:pattern value="\\\\([^/\\])+(\\([^/\\])+)+(\\)?" />
        </xs:restriction>
    </xs:simpleType>
    
    <xs:simpleType name="NamedElementNameString">
        <xs:annotation>
            <xs:documentation>
                Allows a string which starts with alphabets or underscore, followed by any number of character
                except:

                ^ \ / : * ? ' &lt; &gt; |

                And it should not end in whitespace.
            </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:pattern value="^[a-zA-Z_][^\\\/\:\*\?\&quot;\&lt;\&gt;\|\`\'\^]*(?&lt;![\.\s])$" />
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="VirtualDirectoryName">
        <xs:restriction base="xs:string">
            <xs:pattern value="^[a-zA-Z_][^\\/\?;:\`\'\^@&amp;=\+\$,\|&quot;&lt;&gt;]*(?&lt;![\.\s])$" />
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="NonEmptyString">
        <xs:restriction base="xs:string">
            <xs:minLength value="1"/>
            <xs:maxLength value="256"/>
        </xs:restriction>
    </xs:simpleType>
    
</xs:schema>
